import delimited "NC Data\SCC_4to5.csv", clear

preserve

keep year teacherid tch_fem tch_race_black tch_exp
duplicates drop
destring tch_fem, replace force
destring tch_race_black, replace force

count if tch_fem~=.&tch_race_black~=.

summ tch_fem tch_race_black tch_exp

restore

preserve

keep year studentid lag_mathscore lag_readingscore female race_black poverty lep
duplicates drop

count

summ female race_black poverty lep lag_readingscore lag_mathscore

restore

preserve
*class level is same as teacher level obs.
keep year teacherid lag_mathscore lag_readingscore female race_black poverty lep
gen class_size=1

collapse (mean) lag_mathscore lag_readingscore female race_black poverty lep (sum) class_size, by(teacherid year)

count

summ female race_black poverty lep class_size lag_readingscore lag_mathscore

restore
preserve

keep year schoolid districtid teacherid
duplicates drop
gen teacher_count=1
collapse (sum) teacher_count, by(year schoolid districtid)

summ teacher_count

collapse (sum) teacher_count, by(year districtid)

summ teacher_count

restore
keep year schoolid districtid studentid
gen student_count=1
collapse (sum) student_count, by(year schoolid districtid)

summ student_count

collapse (sum) student_count, by(year districtid)

summ student_count
